package de.clapp.qrcode;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Toast;

import com.google.zxing.Result;
import com.google.zxing.client.android.CaptureActivity;

public class MyCaptureActivity extends CaptureActivity
{
    @Override
    public View onCreateView(String name, Context context, AttributeSet attrs)
    {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
        // TODO Auto-generated method stub
        return super.onCreateView(name, context, attrs);
    }
    
    
    public static String ClubID = "";

    public static String TischID = "";

    @Override
    public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor)
    {
        try
        {
            String[] results = rawResult.getText().split("-");
            MyCaptureActivity.ClubID = results[0];
            MyCaptureActivity.TischID = results[1];
            Toast.makeText(this.getApplicationContext(), ClubID + "-" + TischID, Toast.LENGTH_LONG).show();
            this.finish();
            
        }
        catch (Exception e)
        {
            // something has gone wrong
        }
    }
}
